<template>
	<view class="user-coupon-success">
		<view class="user-coupon-success-tips">优惠券创建成功，点击按钮立即分享给好友或客户领取吧</view>
		<view class="coupon-item">
			<view class="coupon-item-left">
				<view class="coupon-price" v-if="couponInfo.type==1">￥<text>{{couponInfo.money}}</text></view>
				<view class="coupon-price" v-if="couponInfo.type==2"><text>{{couponInfo.discount}}</text>折</view>
				<view class="coupon-des" v-if="couponInfo.type==1">满{{couponInfo.satisfy_money}}可用</view>
			</view>
			<view class="coupon-item-center">
				<view class="coupon-name">{{couponInfo.coupon_name}}</view>
				<view class="coupon-time">有效期：{{$u.timeFormat(couponInfo.stop_time,'yyyy-mm-dd')}}</view>
			</view>
		</view>
		<view class="btn"><button open-type="share" type="primary">立即分享</button></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				key: '',
				couponInfo: ''
			};
		},
		onLoad(options) {
			this.key = options.key
			this.couponInfo = JSON.parse(options.info)
		},
		onReady() {
			this.$u.mpShare = {
				title: '这里有一张优惠券，赶紧来领取吧~',
				path: '/my/user-coupon/user-coupon-receive?key='+this.key+'&info='+JSON.stringify(this.couponInfo),
				imageUrl: 'https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/my/receive-1.jpg'
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F8F8F8;
	}
	.user-coupon-success{
		padding: 30rpx;
		.user-coupon-success-tips{
			margin-bottom: 30rpx;
		}
		.coupon-item{
			display: flex;
			background-color: #FFF;
			margin-bottom: 40rpx;
			border-radius: 8rpx;
			overflow: hidden;
			&:last-child{
				margin-bottom: 0;
			}
			.coupon-item-left{
				width: 180rpx;
				height: 150rpx;
				background-color: #F59359;
				color: #FFF;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				position: relative;
				.coupon-price{
					margin-bottom: 10rpx;
					text{
						font-size: 42rpx;
					}
				}
				.coupon-des{
					font-size: 20rpx;
				}
				&::before{
					content: '';
					position: absolute;
					width: 20rpx;
					height: 20rpx;
					background-color: #F8F8F8;
					border-radius: 50%;
					bottom: -10rpx;
					right: -10rpx;
					z-index: 1;
				}
				&::after{
					content: '';
					position: absolute;
					width: 20rpx;
					height: 20rpx;
					background-color: #F8F8F8;
					border-radius: 50%;
					top: -10rpx;
					right: -10rpx;
					z-index: 1;
				}
			}
			.coupon-item-center{
				border-right: dashed 2rpx #E6E6E6;
				flex: 1;
				min-width: 0;
				padding: 0 30rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				.coupon-name{
					font-size: 32rpx;
					margin-bottom: 20rpx;
				}
				.coupon-time{
					color: #999;
					font-size: 24rpx;
				}
			}
			.coupon-item-right text{
				padding: 0 20rpx;
				width: 60rpx;
				text-align: center;
				display: flex;
				flex-direction: column;
				justify-content: center;
				color: #F59359;
				font-size: 24rpx;
				background-color: transparent;
				line-height: normal;
				height: 100%;
				&::after{
					display: none;
				}
			}
		}
		.btn{
			button{
				background-color: #141414;
				font-size: 32rpx;
			}
		}
	}
</style>
